<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="com.jiadakeji.ppm.modules.sys.utils.*" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>发票补打</title>
	<meta name="decorator" content="default"/>
	<link href="${ctxStatic}/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
	<script src="${ctxStatic}/jquery-form/jquery.form.js" type="text/javascript"></script>
	<link href="${ctxStatic}/css/animate.min.css" rel="stylesheet">
	<link href="${ctxStatic}/css/common.css" rel="stylesheet">
	<link href="${ctxStatic}/css/style.min.css?v=4.0.0" rel="stylesheet">
	<OBJECT ID=sk
			CLASSID="clsid:003BD8F2-A6C3-48EF-9B72-ECFD8FC4D49F"
			codebase="NISEC_SKSCX.ocx#version=1,0,0,1" width=0 height=0>
	</OBJECT>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){

				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
	<div class="col-sm-12">
		<div class="tabs-container ">
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/invioce/redoPrinter">发票补打</a></li>
	</ul>
			<div id="tab-1" class="tab-pane active">
				<div class="panel-body boxPanel">
	<form id="inputForm"  action="" method="post" class="form-horizontal">
		<sys:message content="${message}"/>
		<div class="boxHeight">
		<div class="control-group">
			<label class="control-label">发票类型：</label>
			<div class="controls">
				<input id="fplxdm" name="fplxdm" htmlEscape="false" maxlength="10" class="input-xlarge  digits" type="number" min="0"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">发票代码：</label>
			<div class="controls">
				<input id="fpdm" name="fpdm" htmlEscape="false" maxlength="10" class="input-xlarge  digits" type="number" min="0"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">发票号码：</label>
			<div class="controls">
				<input id="fphm" name="fphm" htmlEscape="false" maxlength="10" class="input-xlarge  digits" type="number" min="0"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
			<div class="btnDiv">
			<button type="button" onclick="reDoPrint()" class="btn" >发票补打</button>
		</div>
		</div>
	</form>

<script type="text/javascript">
	function reDoPrint() {

		$.ajax({
            async : false,
			type : "POST",  //提交方式
			url : "${ctx}/invioce/prereDo",//路径
			data : {
			    "fplxdm":$("#fplxdm").val(),
                "fpdm":$("#fpdm").val(),
                "fphm":$("#fphm").val()
			},
			success : function(result) {//返回数据根据结果进行相应的处
				SetParameter();
				SetMargin();
				inviladInvioce(result);

			}

		})
	}

    function SetMargin(){

        $.ajax({
            async : false,
            type : "POST",  //提交方式
            url : "${ctx}/invioce/getMarginProperty",//路径
            data : {
                "fplxdm":$("#fplxdm").val(),
            },
            success : function(result) {//返回数据根据结果进行相应的处
                try
                {
                    ret = sk.Operate(result);
                }
                catch(e)
                {
                    alert(e.message + ",errno:" + e.number);
                }
            }

        })
	}





    function inviladInvioce(result){
        console.log(result);
        var sInputInfo = result;
        try
        {
            ret = sk.Operate(sInputInfo);
            alert(ret);
        }
        catch(e)
        {
            alert(e.message + ",errno:" + e.number);
        }
    }

    function SetParameter()
    {
        var sInputInfo =
            "<?xml version=\"1.0\" encoding=\"gbk\"?>\r\n" +
            "<business id=\"20001\" comment=\"参数设置\">\r\n" +
            "<body yylxdm=\"1\">\r\n" +
            "<servletip>124.225.17.145</servletip>\r\n" +
            "<servletport>8082</servletport>\r\n" +
            "<keypwd>88888888</keypwd>\r\n" +
            "</body>\r\n" +
            "</business>";
        try
        {
            ret = sk.Operate(sInputInfo);
            console.log(ret);
        }
        catch(e)
        {
            alert(e.message + ",errno:" + e.number);
        }
    }

</script>
</body>
</html>